/* CS32 FINAL PROJECT */

package GameEngine;

/**
 * This class holds all enumerations and constants, which essentially serves
 * as a library of all objects, graphics, effects in the game, and is certainly
 * open to extensibility.
 * @author mhfowler
 */
public class GameConstants
{
    /*Constants for speed and acceleration*/
    public final static float JUMP_VELOCITY = 10;
    public final static float MOVE_VELOCITY = 7;
    public final static float GRAVITY_ACCELERATION = (float) 0.5;
    public final static float FRICTION = (float) 0.9;
    public final static float MAX_SPEED = 12;

   // number of special classes we make separate/no buttons for in the level editor
    public final static int SPECIAL_TYPES = 3;
    public final static int WINDOW_CONSTANT = 500;
    public final static int NUM_MOVE_STEPS = 3;

    /* enumeration of all known levels */
    public enum Levels 
    {
        ABSTRACT, PIXRAIN, GEORGEWASHINGTON, EINSTEIN, DEFAULT, CRAZY_COLORS
    }

    public static Levels parseByteToLevels(byte level)
    {
        Levels toReturn = null;
        switch(level)
        {
            case 0:
                toReturn = Levels.ABSTRACT;
                break;
            case 1:
                toReturn = Levels.PIXRAIN;
                break;
            case 2:
                toReturn = Levels.GEORGEWASHINGTON;
                break;
            case 3:
                toReturn = Levels.EINSTEIN;
                break;
            case 4:
                toReturn = Levels.DEFAULT;
                break;
            case 5:
                toReturn = Levels.CRAZY_COLORS;
                break;
        }
        return toReturn;
    }

     /**
      *
      * These are the enumerations of all graphical representations of objects.
      * IMPORTANT!!!!!!!!!!
      * IF you want to add a Graphic, add to the end.
      */
    public enum Graphic
    {
        FAN, VACUUM, WATER, SPRITE,
        APPLE, DOG, MUSHROOM,
        BLUEPLAYER, DEFAULTBACK, CHOMPERS, 
        CURLYPLAYER, PINKPLAYER_WALK, PINKPLAYER_STAY, PINKPLAYER_JUMP,
        WIND, VACUUMWIND, GOAL_POINT, SPAWN_POINT, WALL, META, PORTAL, SPOUT, ICE,
        PINKPLAYER_WALKLEFT, PINKPLAYER_STAYLEFT, PINKPLAYER_JUMPLEFT, PINKWALL, FISH,
        BOMBDROP, JAMESBROWN, GEORGEWASHINGTON, GREENPLAYER_WALK, GREENPLAYER_STAY, GREENPLAYER_JUMP,
        REDPLAYER_WALK, REDPLAYER_STAY, REDPLAYER_JUMP, PURPLEPLAYER_WALK, PURPLEPLAYER_STAY, PURPLEPLAYER_JUMP,
        YELLOWPLAYER_WALK, YELLOWPLAYER_STAY, YELLOWPLAYER_JUMP, GREENPLAYER_WALKLEFT, GREENPLAYER_STAYLEFT, GREENPLAYER_JUMPLEFT,
        REDPLAYER_WALKLEFT, REDPLAYER_JUMPLEFT, REDPLAYER_STAYLEFT, PURPLEPLAYER_WALKLEFT, PURPLEPLAYER_JUMPLEFT,
        PURPLEPLAYER_STAYLEFT, YELLOWPLAYER_WALKLEFT, YELLOWPLAYER_STAYLEFT, YELLOWPLAYER_JUMPLEFT, USESPECIAL, EINSTEIN, ABSTRACT, SPIKE,
        CRAZY_COLORS;
    }
    
     /**
     * This method parses a byte into an Action
     * @param act       action in byte form
     * @return  Action  the corresponding action from the byte
     */
    public static Graphic parseByteToGraphic(byte act)    
    {
        Graphic toReturn = null;
        switch(act)
        {
            case 0:
                toReturn= Graphic.FAN;
                break;
            case 1:
                toReturn= Graphic.VACUUM;
                break;
            case 2:
                toReturn = Graphic.WATER;
                break;
            case 3:
                toReturn = Graphic.SPRITE;
                break;
            case 4:
                toReturn = Graphic.APPLE;
                break;
            case 5:
                toReturn= Graphic.DOG;
                break;
            case 6:
                toReturn= Graphic.MUSHROOM;
                break;
            case 7:
                toReturn= Graphic.BLUEPLAYER;
                break;
            case 8:
                toReturn = Graphic.DEFAULTBACK;
                break;
            case 9:
                toReturn = Graphic.CHOMPERS;
                break;
            case 10:
                toReturn = Graphic.CURLYPLAYER;
                break;
            case 11:
                toReturn= Graphic.PINKPLAYER_WALK;
                break;
            case 12:
                toReturn= Graphic.PINKPLAYER_STAY;
                break;
            case 13:
                toReturn= Graphic.PINKPLAYER_JUMP;
                break;
            case 14:
                toReturn= Graphic.WIND;
                break;
            case 15:
                toReturn= Graphic.VACUUMWIND;
                break;
            case 16:
                toReturn= Graphic.GOAL_POINT;
                break;
            case 17:
                toReturn = Graphic.SPAWN_POINT;
                break;
            case 18:
                toReturn = Graphic.WALL;
                break;
            case 19:
                toReturn = Graphic.META;
                break;
            case 20:
                toReturn = Graphic.PORTAL;
                break;
            case 21:
                toReturn = Graphic.SPOUT;
                break;
            case 22:
                toReturn = Graphic.ICE;
                break;
            case 23:
                toReturn = Graphic.PINKPLAYER_WALKLEFT;
                break;
            case 24:
                toReturn = Graphic.PINKPLAYER_STAYLEFT;
                break;
            case 25:
                toReturn = Graphic.PINKPLAYER_JUMPLEFT;
                break;
                  case 26:
                toReturn = Graphic.PINKWALL;
                break;
            case 27:
                toReturn = Graphic.FISH;
                break;
            case 28:
                toReturn = Graphic.BOMBDROP;
                break;
            case 29:
                toReturn = Graphic.JAMESBROWN;
                break;
            case 30:
                toReturn = Graphic.GEORGEWASHINGTON;
                break;
            case 31:
                toReturn = Graphic.GREENPLAYER_WALK;
                break;
                        case 32:
                toReturn = Graphic.GREENPLAYER_STAY;
                break;
            case 33:
                toReturn = Graphic.GREENPLAYER_JUMP;
                break;
                        case 34:
                toReturn = Graphic.REDPLAYER_WALK;
                break;
                        case 35:
                toReturn = Graphic.REDPLAYER_STAY;
                break;
                        case 36:
                toReturn = Graphic.REDPLAYER_JUMP;
                break;
                        case 37:
                toReturn = Graphic.PURPLEPLAYER_WALK;
                break;
                        case 38:
                toReturn = Graphic.PURPLEPLAYER_STAY;
                break;
                        case 39:
                toReturn = Graphic.PURPLEPLAYER_JUMP;
                break;
                        case 40:
                toReturn = Graphic.YELLOWPLAYER_WALK;
                break;
                        case 41:
                toReturn = Graphic.YELLOWPLAYER_STAY;
                break;
                        case 42:
                toReturn = Graphic.YELLOWPLAYER_JUMP;
                break;
                        case 43:
                toReturn = Graphic.GREENPLAYER_WALKLEFT;
                break;
                        case 44:
                toReturn = Graphic.GREENPLAYER_STAYLEFT;
                break;
                        case 45:
                toReturn = Graphic.GREENPLAYER_JUMPLEFT;
                break;
                        case 46:
                toReturn = Graphic.REDPLAYER_WALKLEFT;
                break;
                        case 47:
                toReturn = Graphic.REDPLAYER_JUMPLEFT;
                break;
                        case 48:
                toReturn = Graphic.REDPLAYER_STAYLEFT;
                break;
                        case 49:
                toReturn = Graphic.PURPLEPLAYER_WALKLEFT;
                break;
                        case 50:
                toReturn = Graphic.PURPLEPLAYER_JUMPLEFT;
                break;
                        case 51:
                toReturn = Graphic.PURPLEPLAYER_STAYLEFT;
                break;
                        case 52:
                toReturn = Graphic.YELLOWPLAYER_WALKLEFT;
                break;
                        case 53:
                toReturn = Graphic.YELLOWPLAYER_STAYLEFT;
                break;
                        case 54:
                toReturn = Graphic.YELLOWPLAYER_JUMPLEFT;
                break;
            case 55:
                toReturn = Graphic.USESPECIAL;
                break;
            case 56:
                toReturn = Graphic.EINSTEIN;
                break;
            case 57:
                toReturn = Graphic.ABSTRACT;
                break;
                   case 58:
                toReturn = Graphic.SPIKE;
                break;
            case 59:
                toReturn = Graphic.CRAZY_COLORS;
                break;
        }
        return toReturn;
    }

       /** These are enumerations of all materials that objects can be made of,
     *  which is essentially a way to group objects beyond just their object class.
     *  A fireball and a pit of lava may be different object classes, but they
     *  might both be material fire, which gets taken into account during collisions.*/

    /**
     * META_ELEMENTS should be used for elements like the spawn and goal points,
     * which don't interact with players except in a very "meta" sort of way.
     */
    public enum Material
    {
        PLAYER, WALL, WATER,
        BOUNCY, FIRE, ICE,
        SPIKY, META_ELEMENTS,
        WIND, VACUUM, BOMB, PORTAL
    }

    public enum Modifier
    {
        UPLEFT, UP, UPRIGHT, LEFT, RIGHT, DOWNLEFT, DOWN, DOWNRIGHT
    }

    /** These are the enumerations of all effects that objects can have on eachother.
     *  The actual content of what these effects do is written into the class of the object
     *  under the method receive effect, however using enumeration allows us to have
     *  different objects utilize the same effects to come up with a form of a library. */
    public enum Effect 
    {
        DESTROY, NOTIFY, FREEZE, EXPLOSION,
        TRANSMUTE, SLOW, SPEED, WIND, CURRENT, WALL,
        PERSISTENT_SPEED , REVERSE, TELEPORT, SLIPPERY
    }



    /** These are the enumerations of the possible game states which represent the
     * overall status of the game */
    public enum GameState
    {
        ONGOING, VICTORY, ERROR
    }

    /** These are the enumerations of the possible actions that a user can make, and will
     * be sent to the GameEngine for processing */
    public enum Action 
    {
        MOVERIGHT, MOVELEFT, JUMP, USESPECIAL
    }
    
    /**
     * This method parses a byte into an Action
     * @param act       action in byte form
     * @return  Action  the corresponding action from the byte
     */
    public static Action parseByteToAction(byte act)    
    {
        Action toReturn = null;
        switch(act)
        {
            case 0:
                toReturn= Action.MOVERIGHT;
                break;
            case 1:
                toReturn= Action.MOVELEFT;
                break;
            case 2:
                toReturn = Action.JUMP;
                break;
            case 3:
                toReturn = Action.USESPECIAL;
                break;
        }
        return toReturn;
    }

    /** These are the enumerations of objects in the game, while each object will have its own
     * class, enumerating all objects will allow us to more easily parse an XML into a list of
     * objects which the levelConstructor can then generate objects for. There can also be a
     * many to one mapping from enumerations to object type, allowing for such things as BIGFAN
     * and LITTLEFAN to map to the same object, but cause the constructor to intialize the object
     * with different attributes. And store a library... */
    public enum Thing
    {
        PINKWALL, FISH, SPOUT, BIGFAN, LITTLEFAN, CHOMPERS, BIGVACUUM, LITTLEVACUUM, JACUZZI,
        SPAWNPOINT, GOALPOINT, WALLBLOCK, PORTAL, BIGBOMB, PLAYER, WALL, ICE, SPIKE
    }

    /** These are the enumerations of the types of specials that players can have */
    public enum Special
    {
        TRANSMUTER, TIME, EXPLODER, BUILDER
    }

    public static Special parseByteToSpecial(byte spec)
    {
        Special toReturn = null;
        switch(spec)
        {
            case 0:
                toReturn= Special.TRANSMUTER;
                break;
            case 1:
                toReturn= Special.TIME;
                break;
            case 2:
                toReturn = Special.EXPLODER;
                break;
            case 3:
                toReturn = Special.BUILDER;
                break;
        }
        return toReturn;
    }

    /** These are the enumerations of all screens that will ever exist in the GUI */
    public enum Screen
    {
        WELCOM, STARTGAME, CHOOSEPLAYER,
        JOINGAME, EDITOR, INGAME, WAITING,
        VICTORY
    }


}

